<?php

namespace app\admin\model\system;

use think\Model;


class Recharge extends Model
{

    

    

    // 表名
    protected $name = 'system_recharge';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'level_type_text',
        'is_yellow_text'
    ];
    

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }

    
    public function getLevelTypeList()
    {
        return ['1' => __('Level_type 1'), '2' => __('Level_type 2'), '3' => __('Level_type 3')];
    }

    public function getIsYellowList()
    {
        return ['1' => __('Is_yellow 1'), '2' => __('Is_yellow 2')];
    }


    public function getLevelTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['level_type']) ? $data['level_type'] : '');
        $list = $this->getLevelTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getIsYellowTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_yellow']) ? $data['is_yellow'] : '');
        $list = $this->getIsYellowList();
        return isset($list[$value]) ? $list[$value] : '';
    }



}
